<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>叩丁狼权限管理系统</title>
    <#include "../common/header.ftl" >
    <script type="text/javascript" src="/jquery/plugins/jquery.form.js"></script>
    <script type="text/javascript" src="/jquery/plugins/jquery.bootstrap.min.js"></script>
    <style>
        .modal-body img {
            width: 100%;
        }
    </style>
    <script>
        $(function () {
            // 推荐游记按钮
            $(".edit_Btn").click(function () {
                $("#inputModal").val("");
                // 清除文章封面
                $("#coverUrl").attr("src", " ");
                //清除表单数据
                $("#editForm input,select").val("");

                // 获取绑定数据
                var json = $(this).data("json");
                // 回显数据
                if (json) {  // 编辑按钮
                    //回显id隐藏域
                    $("input[name='id']").val(json.id);
                    $("input[name='name']").val(json.name);
                    $("select[name='scenic.id']").val(json.scenicId);
                    $("input[name='price']").val(json.price);
                }
                $("#inputModal").modal("show");
                // 文件框使用change事件

            });

            // 保存模态框里的数据
            $(".btn-submit").click(function () {
                //将表单的提交方式修改为ajax异步提交
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.alert("温馨提示", "操作成功!");
                        setTimeout(function () {
                            window.location.reload();
                        }, 2000);
                    }
                });
            });

        });
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#assign currentMenu="ticket"/>
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">景点门票管理</h1>
                </div>

                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/ticket/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                               placeholder="请输入景点名称">
                    </div>
                    <input type="submit" id="btn_query" class="btn btn-default btn-success" value="查询">
                    <a href="javascript:;" class="btn btn-success edit_Btn">添加景点门票</a>
                </form>
            </div>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>门票名称</th>
                    <th>价格</th>
                    <th>所属景点</th>
                </tr>
                </thead>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index+1}</td>
                        <td>${entity.name}</td>
                        <td>${entity.price}</td>
                        <td>${entity.scenic.name}</td>
                        <td>
                            <a href="javascript:;" class="edit_Btn" data-json='${(entity.json)!}'>修改</a> |
                            <a href="javascript:;" class="btn-delete" data-url="/ticket/delete.do?id=${entity.id}">删除</a>
                        </td>

                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl" />
        </div>
    </div>
</div>
<#--编辑模态框-->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑景点门票</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/ticket/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" name="id">
                    <div class="form-group">
                        <label for="name" class="col-sm-4 control-label">名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="price" class="col-sm-4 control-label">价格：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="price">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="scenic.id" class="col-sm-4 control-label">所属景点：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="scenic.id">
                                <#list scenicList as scenic>
                                    <option value="${scenic.id}">${scenic.name}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>